// components/imageLoader/index.js
Component({

  externalClasses: ['custom-class'],

  /**
   * 组件的属性列表
   */
  properties: {
    type: String,
    mode: {
      type: String,
      value: 'aspectFill'
    },
    defaultImage: {
      type: String,
      value: '/images/default_img.png'
    },
    src: String,
  },

  /**
   * 组件的初始数据
   */
  data: {
    isLoading: true
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 当图片载入完毕时触发
    onFinishLoad (event) {
      this.setData({
        isLoading: false
      })
      this.triggerEvent('load', {
        event: event
      }, {})
    },
    // 当错误发生时触发
    onErrorLoad (event) {
      this.triggerEvent('error', {
        event: event
      }, {})
    }
  }
})
